package com.example.dormitorymanagement.config;

import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

@Configuration
@Profile("!prod") // 生产环境禁用Swagger
public class SwaggerConfig {

    @Bean
    public OpenAPI dormitoryManagementOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("宿舍管理系统API")
                        .description("简易宿舍管理系统API文档")
                        .version("v1.0")
                        .contact(new Contact()
                                .name("技术支持")
                                .email("support@example.com")))
                .externalDocs(new ExternalDocumentation()
                        .description("Wiki文档")
                        .url("https://wiki.example.com/docs"));
    }

    @Bean
    public GroupedOpenApi publicApi() {
        return GroupedOpenApi.builder()
                .group("public-api")
                .pathsToMatch("/api/**")
                .build();
    }
}